﻿/**
 *
 * @file    FITKVAOneXMLReader.h
 * @brief   VA One XML读取
 * @author  LiBaojun (libaojunqd@foxmail.com)
 * @date    2024-10-11
 *
 */
#ifndef _FITKVAONE_XML_READER_H___
#define _FITKVAONE_XML_READER_H___

#include "FITK_Interface/FITKInterfaceIO/FITKAbstractRapidXMLReader.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"

namespace rapidxml
{
    template<class Ch>
    class xml_node;
}

namespace VAOne
{
    class FITKVAOneXMLIOInterface;
    class FITKVAOneXMLHash;
    /**
     * @brief   VA One XML读取类
     * @author  LiBaojun (libaojunqd@foxmail.com)
     * @date    2024-10-11
     */
    class FITKVAOneXMLReader : public Interface::FITKAbstractRapidXMLReader
    {
    public:
        /**
         * @brief   进度类型枚举
         * @author  TanDongYang (tandongyang@diso.cn)
         * @date    2024-11-20
         */
        enum VAOneXMLPercentType
        {
            Per_First = 0,               ///< 开始
            Per_GlobalFrequencyDomain,   ///< 全局频率
            Per_Nodes,                   ///< 节点
            Per_Spectra,                 ///< 频谱
            Per_Materials,               ///< 材料
            Per_FEMaterials,             ///< FE材料
            Per_PhysicalProperties,      ///< 物理属性
            Per_FEProperties,              ///< FE属性
            Per_NoiseControlTreatments,  ///< 声学包
            Per_Faces,                   ///< 面
            Per_Subsystems,              ///< 子系统
            Per_Sinks,                   ///< 半无限流体
            Per_PowerSources,            ///< 能量源
            Per_Junctions,               ///< 交点/耦合
            Per_Constraints,             ///< 约束
            Per_Connections,             ///< 连接
            Per_Finish,                  ///< 结束
            Per_FESubsystems,            ///< 结构FE子系统
            Per_AcousticFESubSystems,    ///< 腔体FE子系统
            Per_FESubSystemElementList,  ///< FE子系统单元列表
        };
        /**
         * @brief     Construct a new FITKVAOneXMLReader object
         * @param[i]  interface 组件指针，可传递参数
         * @param[o]  isSuccess 是否执行成功
         * @author    LiBaojun (libaojunqd@foxmail.com)
         * @date      2024-10-11
         */
        explicit FITKVAOneXMLReader(FITKVAOneXMLIOInterface* interface, bool & isSuccess);
        /**
         * @brief   Destroy the FITKVAOneXMLReader object
         * @author  LiBaojun (libaojunqd@foxmail.com)
         * @date    2024-10-11
         */
        virtual ~FITKVAOneXMLReader();
        /**
         * @brief   执行读取操作
         * @author  LiBaojun (libaojunqd@foxmail.com)
         * @date    2024-10-11
         */
        void run() override;
        /**
         * @brief     获取XML哈希表数据接口
         * @return    FITKVAOneXMLHash*
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-20
         */
        FITKVAOneXMLHash* getXMLHash();
    private:
        /**
         * @brief     读取Model子节点接口（顺序读取）
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-06
         */
        bool readModelChildNode();
        /**
         * @brief     适配器读取操作接口
         * @param[i]  nodeName 节点名称
         * @return    是否执行成功
         * @author    lilongyuan (lilongyuan@diso.cn)
         * @date      2025-02-21
         */
        bool adaptorRead(QString nodeName);
    private:
        /**
         * @brief     更新进度条
         * @param[i]  type 进度类型
         * @author    TanDongYang (tandongyang@diso.cn)
         * @date      2024-11-19
         */
        void updatePercent(VAOneXMLPercentType type);
        /**
          * @brief     打印控制台消息
          * @param[i]  level 打印级别 1 normal 2 warning 3error
          * @param[i]  str 打印的信息
          * @author    LiBaojun (libaojunqd@foxmail.com)
          * @date      2024-03-08
          */
        void consoleMessage(int level, const QString& str) override;
    private:
        /**
         * @brief   组件对象指针
         * @author  LiBaojun (libaojunqd@foxmail.com)
         * @date    2024-10-11
         */
        FITKVAOneXMLIOInterface* _compInterface{};
        /**
         * @brief   是否执行成功
         * @author  LiBaojun (libaojunqd@foxmail.com)
         * @date    2024-10-11
         */
        bool & _isSuccess;
        /**
         * @brief   读取XML哈希表指针，读取的映射信息存放在这里
         * @author  lilongyuan (lilongyuan@diso.cn)
         * @date    2025-02-20
         */
        FITKVAOneXMLHash* _readerXMLHash{};
    };
}
#endif _FITKVAONE_XML_READER_H___
